package com.lineage.server.serverpackets;

import com.lineage.server.model.Instance.L1PcInstance;
import com.lineage.server.model.L1Character;

public class S_CharVisualUpdate extends ServerBasePacket {
  private byte[] _byte;
  
  public S_CharVisualUpdate(int objid, int weaponType) {
    this._byte = null;
    writeC(119);
    writeD(objid);
    writeC(weaponType);
  }
  
  public S_CharVisualUpdate(L1PcInstance cha) {
    this._byte = null;
    writeC(119);
    writeD(cha.getId());
    if (cha.getWeapon() != null) {
      int weapontype = cha.getWeapon().getItem().getType1();
      if (weapontype == 24) {
        switch (cha.getTempCharGfx()) {
          case 6137:
          case 6142:
          case 6147:
          case 6152:
          case 6157:
          case 9205:
          case 9206:
          case 12280:
          case 12283:
          case 12681:
          case 13152:
          case 13153:
          case 17541:
            writeC(83);
            cha.sendPackets(new S_SkillIconGFX(cha.getTempCharGfx(), true));
            break;
          default:
            writeC(cha.getCurrentWeapon());
            cha.sendPackets(new S_SkillIconGFX(cha.getTempCharGfx(), false));
            break;
        } 
      } else {
        writeC(cha.getCurrentWeapon());
      } 
      writeC(255);
      writeC(255);
    } 
  }
  
  public S_CharVisualUpdate(L1Character cha, int status) {
    this._byte = null;
    writeC(119);
    writeD(cha.getId());
    writeC(status);
    writeC(255);
    writeC(255);
  }
  
  public byte[] getContent() {
    if (this._byte == null)
      this._byte = getBytes(); 
    return this._byte;
  }
}
